package com.jerry.reflect;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @author Jerry
 * @date 2016-12-05
 */
public class test3 {
    public static void main(String[] args) {
        ExpressionParser expressionParser = new SpelExpressionParser();
        Expression ex = expressionParser.parseExpression("'heloworld'");
        System.out.println(ex.getValue());
        StandardEvaluationContext context = new StandardEvaluationContext();
        Map<String,Object> map = new HashMap<>();
        map.put("xiaoming","xiaoming");
        map.put("xiaowen","xiaowen");
        context.setVariable("map",map);
        System.out.println(expressionParser.parseExpression("#map[xiaowen]").getValue(context,String.class));;
    }
}

